/**
 * Created by commy on 2015/4/30.
 */
var jsparser = module.exports = function(req,res,next){
    if(req.header('content-type')=='application/json'){

        var str = 'str='; //为了eval能够执行不出错
        req.setEncoding('utf8');
        req.on('data',function(data){
            str+=data;
        });
        req.on('end',function(data){
            if(data)
            str+=data;
            try{
                req.body = eval(str);
            }catch(err){
                next(err);
                return;
            }
            next();
        });
    }else{
        next();
    }
}